<?php

/**
 * IndexController - The default controller class
 * 
 * @author
 * @version 
 */

class IndexController extends Zend_Controller_Action 
{
	public function __call($name, $args)
	{
		require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'PagesController.php';
		$pagesController = new PagesController($this->getRequest(), $this->getResponse(), $this->getInvokeArgs());
		$pagesController->display();
	}

	/**
	 * Return the Request object
	 *
	 * @return Zend_Controller_Request_Http
	 */
	public function getRequest()
	{
		return $this->_request;
	}


	public function indexAction()
	{
		$form = $this->getAddCommentForm();

		if ($this->getRequest()->isPost()) {
			if ($form->isValid($_POST)) {
				$values = $form->getValues();
				$this->view->values = $values;
			}
		}

		$this->view->form = $form;
	} // end function indexAction

	/**
	 * This function returns the form used for
	 * adding comments in blog application
	 */
	public static function getAddCommentForm()
	{
		require_once 'Zend/Form.php';
		$form = new Zend_Form(array(
			'method'   => 'post',
			'elements' => array(
				'comments' => array('textarea', array(
					'required' => true,
					'label' => 'Comments:',
					'rows' => '10',
					'cols' => '40'
				)),
				'submit' => array('submit', array(
					'label' => 'Add Comments'
				))
			),
		));

		return $form;
	} // end function getAddCommentForm


} // class IndexController